/*
Building a Clean and Loyal State: The Strategic Dilemma of an Anti-corruption Campaign Under One-Party Rule
Authors: Tianyang Xi, Yang Yao and Qian Zhang
Date: Oct, 30, 2023
Stata Version 14.0
Operating System: Micrsoft Windows 10
*/

clear
set more off
capture log close

*-------------------------------Table A4------------------------------------*
use "investigation_2013_2021_exclude_ppl.dta" ,clear

*column (1)-(4)
hetprobit lm ability connectionc_yes jiao1_a_yes ,het(ability jiao1_a_yes) cluster(location)
hetprobit lm ability connectionc_yes jiao1_a_yes xs_2014 xs_2015 xs_2016 xs_2017 xs_2018 xs_2019 xs_2020 xs_2021 college_onjob_yes mini_nat gender year2014 year2015 year2016 year2017 year2018 year2019 year2020 year2021, het(ability jiao1_a_yes connectionc_yes) cluster(location)
hetprobit lm ability connectionc jiao1_a,het(ability jiao1_a_yes connectionc) cluster(location)
hetprobit lm ability connectionc jiao1_a xs_2014 xs_2015 xs_2016 xs_2017 xs_2018 xs_2019 xs_2020 xs_2021 college_onjob_yes mini_nat gender year2014 year2015 year2016 year2017 year2018 year2019 year2020 year2021, het(ability jiao1_a_yes connectionc) cluster(location)

*calculate marginal effects in column (1):
hetprobit lm ability connectionc_yes jiao1_a_yes ,het(ability jiao1_a_yes) cluster(location)
margins, dydx(ability connectionc_yes jiao1_a_yes ) 

*calculate marginal effects in column (2):
hetprobit lm ability connectionc_yes jiao1_a_yes xs_2014-xs_2021 college_onjob_yes mini_nat gender year2014-year2021, het(ability jiao1_a_yes connectionc_yes) cluster(location)
margins, dydx(connectionc_yes jiao1_a_yes) 
gen ability_int=int(ability*100)/100
hetprobit lm ability_int connectionc_yes jiao1_a_yes xs_2014-xs_2021 college_onjob_yes mini_nat gender year2014-year2021, het(ability jiao1_a_yes connectionc_yes) cluster(location)
margins, dydx(ability_int) at(ability_int=(-0.09(0.01)0.10))   //calculate marginal effects of capability=0.46

*calculate marginal effects in column (3):
hetprobit lm ability_int connectionc jiao1_a,het(ability jiao1_a_yes connectionc) cluster(location)
margins, dydx(ability_int jiao1_a)
hetprobit lm ability connectionc jiao1_a,het(ability jiao1_a_yes connectionc) cluster(location)
margins, dydx(connectionc)

*calculate marginal effects in column (4):
hetprobit lm ability connectionc jiao1_a xs_2014 xs_2015 xs_2016 xs_2017 xs_2018 xs_2019 xs_2020 xs_2021 college_onjob_yes mini_nat gender year2014 year2015 year2016 year2017 year2018 year2019 year2020 year2021, het(ability jiao1_a_yes connectionc) cluster(location)
margins, dydx(ability connectionc jiao1_a)

